<?php
class UserModel extends DeanAbstractModel{
	
	public function __construct($table, $primary) {
		parent::__construct($table, $primary);
	}
	
	public function getUserList()
	{
		$this->logger->info("UserModel::getUserList");
		$result = array();
		
		try{
			$select = $this->select();
			$rowset = $this->fetchAll($select);
		
			$this->logger->info("Found ".count($rowset)." row(s) in user table.");
					
			foreach($rowset as $k => $v)
			{
				$userLogic = new UserLogic($v->user_name, $v->user_password, $v->user_is_admin, $v->image_id, $v->user_email);
				$result[] = $userLogic;
			}
		}
		catch(Exception $e)
		{
			throw $e;
		}
		return $result;
	} 
	
	
	public static function getInstance($table, $primary) {
//		$logger->info("UserModel::getInstance => [".$table."/".$primary."]");
		if(is_null(self::$_instance)) self::$_instance = new UserModel($table, $primary);
		if(self::$_instance->_name != $table) self::$_instance = new UserModel($table,$primary);
		return self::$_instance;
	}
	
	public static function getDbTable()
	{
		if (null === $self::_dbTable) {
			$self::setDbTable('UserModel');
		}
		return $self::_dbTable;
	}
	
	
}